﻿using System;
using System.Collections;

namespace AcmeSportsStore
{
    class CustomersItemIndexerByName: Indexer
    {
        public class UniquenessBasedComparer : IComparer
        {
            public int Compare(object x, object y)
            {
                CustomersItem ciX = (CustomersItem)x;
                CustomersItem ciY = (CustomersItem)y;

                int res = ciX.CustName.CompareTo(ciY.CustName);
                if (res == 0)
                {
                    res = ciX.CustId.CompareTo(ciY.CustId);
                }
                return res;
            }
        }

        public class FieldComparer : IComparer
        {
            public int Compare(object x, object y)
            {
                CustomersItem ciX = (CustomersItem)x;
                CustomersItem ciY = (CustomersItem)y;

                int res = ciX.CustName.CompareTo(ciY.CustName);
                return res;
            }
        }

         public readonly static UniquenessBasedComparer UBComp
            = new UniquenessBasedComparer();

        public readonly static FieldComparer FComp
            = new FieldComparer();

        public CustomersItemIndexerByName()
            : base(UBComp, FComp)
        {
        }
    }
}
